﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>    


		<head>
		<script type="text/javascript" src="<c:url value='/easyui/datagrid-detailview.js'/>"></script>
		<SCRIPT language=JAVASCRIPT src='<c:url value="/js/grid.js"/>'></SCRIPT>
		<script type="text/javascript">
			$(function(){
				  init();
			});

			function init(){
				$('#t-dg').datagrid({
				loadMsg:'',
				view:detailview,
				detailFormatter:function(index,row){
				  var content = '';
          
          
          
          if (row.clientname)  {
   content += '<span style="color:blue;font-weight:700">客户姓名：</span></br>';
   content += '<div style="padding:5px">'+ row.clientname.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.clientemail)  {
   content += '<span style="color:blue;font-weight:700">客户电子邮箱：</span></br>';
   content += '<div style="padding:5px">'+ row.clientemail.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.clientphone)  {
   content += '<span style="color:blue;font-weight:700">客户电话：</span></br>';
   content += '<div style="padding:5px">'+ row.clientphone.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.clientmsg)  {
   content += '<span style="color:blue;font-weight:700">客户留言信息：</span></br>';
   content += '<div style="padding:5px">'+ row.clientmsg.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.replydate)  {
   content += '<span style="color:blue;font-weight:700">客户留言时间：</span></br>';
   content += '<div style="padding:5px">'+ row.replydate.replace(/\r\n/gi,'<br/>')+'</div>';
}

           
					return '<div style="padding:5px">' + content + '</div>';
				}
				
			});
				
			}
			
			
			
			
			
			var actionUrl;
			function newItem(){
				$('#dlg').dialog('setTitle', '新增留言').dialog('open');
				$('#myform').form('clear');
				actionUrl = '<c:url value="/portal/Reply/saveReply"/>';
			}
			
			function editItem(){
				var t = $('#t-dg');
				var row = t.datagrid('getSelected');
				if (row){
					$('#myform').form('load', row);
					$('#dlg').dialog('setTitle', '修改留言').dialog('open');
					actionUrl = '<c:url value="/portal/Reply/updateReply"/>?id=' + row.id;
				}
			}
			
			
			
			
			function deleteItem(){
				var t = $('#t-dg');
				var row = t.datagrid('getSelected');
				if (row){
					$.messager.confirm('删除确认', '是否确定要删除选择留言?', function(r){
						if (r){
					$.ajax({
						url:'<c:url value="/portal/Reply/destroyReply"/>?id=' + row.id,
						type:'post',
						success:function(){		
							$('#t-dg').datagrid('reload');
						}
					});
						}
						});
				}
			}
			
			function saveItem(){
				$('#myform').form('submit', {
					url:actionUrl,
					onSubmit:function(){
						return $('#myform').form('validate');
					},
					success:function(data){
						var data = eval('('+data+')');
						if (data.success){
							$('#dlg').dialog('close');
							$('#t-dg').datagrid('reload');
						} else {
							$.messager.show({
								title:'保存失败',
								msg:'<pre>'+data.msg+'</pre>'
							});
						}
					}
				});
			}
			
			function doQuery(value){
				$('#t-dg').datagrid('load', {
					q: value
				});
			}
			
			
			function batpassItem(){
				var t = $('#t-dg');
				var rows = t.datagrid('getSelections');
				var ids = [];			
				if (rows){
					for(var i = 0, row; row = rows[i]; i++){
						ids.push(row.id);
					}
					
					$.messager.confirm('批量通过确认', '是否确定要批量通过选择留言信息?', function(r){
							if (r){
					$.ajax({
						url:'<c:url value="/portal/reply/batpassReply"/>?ids=' + ids,
						type:'post',
						success:function(){
							$('#t-dg').datagrid('reload');
						}
					});
				}});
					
				}
			}
			
			function passItem(){				
				var t = $('#t-dg');
				if (isSingleSelect(t)){
				var row = t.datagrid('getSelected');
				if (row){
					
					$.messager.confirm('通过确认', '是否确定要通过选择留言信息?', function(r){
							if (r){
					$.ajax({
						url:'<c:url value="/portal/reply/passReply"/>?id=' + row.id,
						type:'post',
						success:function(){
							$('#t-dg').datagrid('reload');
						}
					});
				}});
					
				}
				}
			}
			
			function batunpassItem(){
				var t = $('#t-dg');
				var rows = t.datagrid('getSelections');
				var ids = [];			
				if (rows){
					for(var i = 0, row; row = rows[i]; i++){
						ids.push(row.id);
					}
					
					$.messager.confirm('批量通过确认', '是否确定要批量不通过选择留言信息?', function(r){
							if (r){
					$.ajax({
						url:'<c:url value="/portal/reply/batunpassReply"/>?ids=' + ids,
						type:'post',
						success:function(){
							$('#t-dg').datagrid('reload');
						}
					});
				}});
					
				}
			}
			
			function unpassItem(){
				var t = $('#t-dg');
				if (isSingleSelect(t)){
				var row = t.datagrid('getSelected');
				if (row){
					
					$.messager.confirm('不通过确认', '是否确定要不通过选择留言信息?', function(r){
							if (r){
					$.ajax({
						url:'<c:url value="/portal/reply/unpassReply"/>?id=' + row.id,
						type:'post',
						success:function(){
							$('#t-dg').datagrid('reload');
						}
					});
				}});
					
				}
				}
			}
			
			function formatstatus(value){
				if (value == "0") 
					return "<font color=blue>通过审核</font>";
				else
					return "<font color=red>待审核</font>";
			}
		</script>
	</head>
	<body>
		<div class="easyui-layout" fit="true">
			<div region="north" border="false" style="height:40px;padding:5px;overflow:hidden;">
			<div style="padding-top:3px;float:left">
			<input class="easyui-searchbox" prompt="按客户名称|留言内容|客户电话进行查询" searcher="doQuery" style="width:300px"></input>
  		</div>
		<div style="float:left">
			<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteItem()">删除留言</a>			
		</div>
		<div style="float:right">		
			<a href="#" class="easyui-linkbutton" iconCls="icon-ok" plain="true" onclick="batpassItem()">批量通过审核</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="batunpassItem()">批量取消通过</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-ok" plain="true" onclick="passItem()">通过审核</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="unpassItem()">取消通过</a>
			</div>
	</div>
			
			
			<div region="center" border="false">
	      <table id="t-dg" style="display:none;"
						url="<c:url value='/portal/Reply/getReplyItems'/>"
						 rownumbers="true" pagination="true"
						border="false" fit="true" fitColumns="true">
					<thead>
						<tr>
						<th field="ck" checkbox="true"></th>
							<th field="local_id" width="100" sortable="true">对应房源编号</th>
<th field="score" width="100" sortable="true">评分</th>
<!-- <th field="toweb" width="100" sortable="true">显示</th> -->
<th field="passflag" width="100" sortable="true" formatter="formatstatus">审核</th>
<th field="clientname" width="100" sortable="true">客户姓名</th>
<th field="clientphone" width="100" sortable="false">客户电话</th>
<th field="replydate" width="100" sortable="true">客户留言时间</th>

						</tr>
					</thead>
				</table>			
			</div>
		</div>
		
		
		
			
		
		
		
		
	</body>
